<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">

<title>class AboutYou::SDK::Model::Variant - RDoc Documentation</title>

<link href="../../../fonts.css" rel="stylesheet">
<link href="../../../rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "../../../";
</script>

<script src="../../../js/jquery.js"></script>
<script src="../../../js/navigation.js"></script>
<script src="../../../js/search_index.js"></script>
<script src="../../../js/search.js"></script>
<script src="../../../js/searcher.js"></script>
<script src="../../../js/darkfish.js"></script>


<body id="top" role="document" class="class">
<nav role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../../../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../../../table_of_contents.html#pages">Pages</a>
    <a href="../../../table_of_contents.html#classes">Classes</a>
    <a href="../../../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  <div id="class-metadata">
    
    <div id="parent-class-section" class="nav-section">
  <h3>Parent</h3>

  
  <p class="link">Object
  
</div>

    <div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">
  
  
    <li><a class="include" href="AbstractModel.html">AboutYou::SDK::Model::AbstractModel</a>
  
  
  </ul>
</div>

    
    <!-- Method Quickref -->
<div id="method-list-section" class="nav-section">
  <h3>Methods</h3>

  <ul class="link-list" role="directory">
    
    <li ><a href="#method-c-create_from_json">::create_from_json</a>
    
    <li ><a href="#method-i-facet_group">#facet_group</a>
    
    <li ><a href="#method-i-generate_facet_group_set">#generate_facet_group_set</a>
    
    <li ><a href="#method-i-image">#image</a>
    
    <li ><a href="#method-i-image_by_hash">#image_by_hash</a>
    
    <li ><a href="#method-i-parse_facet_ids">#parse_facet_ids</a>
    
    <li ><a href="#method-i-parse_images">#parse_images</a>
    
    <li ><a href="#method-i-quantity_per_pack">#quantity_per_pack</a>
    
    <li ><a href="#method-i-select_image">#select_image</a>
    
    <li ><a href="#method-i-size">#size</a>
    
    <li ><a href="#method-i-size_group_id">#size_group_id</a>
    
  </ul>
</div>

  </div>
</nav>

<main role="main" aria-labelledby="class-AboutYou::SDK::Model::Variant">
  <h1 id="class-AboutYou::SDK::Model::Variant" class="class">
    class AboutYou::SDK::Model::Variant
  </h1>

  <section class="description">
    
<p>This class represents a variant model</p>

  </section>

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    
    <section class="attribute-method-details" class="method-section">
      <header>
        <h3>Attributes</h3>
      </header>

      
      <div id="attribute-i-about_number" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">about_number</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer about number id</p>
        
        </div>
      </div>
      
      <div id="attribute-i-additional_info" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">additional_info</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>additional information</p>
        
        </div>
      </div>
      
      <div id="attribute-i-color" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">color</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>String color</p>
        
        </div>
      </div>
      
      <div id="attribute-i-created_date" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">created_date</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer creation date</p>
        
        </div>
      </div>
      
      <div id="attribute-i-ean" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">ean</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>String ean</p>
        
        </div>
      </div>
      
      <div id="attribute-i-facet_groups" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">facet_groups</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Array of <a href="FacetGroup.html">AboutYou::SDK::Model::FacetGroup</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-facet_ids" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">facet_ids</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Array of Integer <a
href="Variant.html#attribute-i-facet_ids">#facet_ids</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-factory" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">factory</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>instance of <a
href="../Factory/DefaultModelFactory.html">AboutYou::SDK::Factory::DefaultModelFactory</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-first_active_date" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">first_active_date</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer first active data</p>
        
        </div>
      </div>
      
      <div id="attribute-i-first_sale_date" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">first_sale_date</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>integer first Sale data</p>
        
        </div>
      </div>
      
      <div id="attribute-i-id" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">id</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer id</p>
        
        </div>
      </div>
      
      <div id="attribute-i-images" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">images</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Array of <a href="Image.html">AboutYou::SDK::Model::Image</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-is_default" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">is_default</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Boolean is variant default for product or not</p>
        
        </div>
      </div>
      
      <div id="attribute-i-length" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">length</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer length</p>
        
        </div>
      </div>
      
      <div id="attribute-i-old_price" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">old_price</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer old price</p>
        
        </div>
      </div>
      
      <div id="attribute-i-price" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">price</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer price</p>
        
        </div>
      </div>
      
      <div id="attribute-i-product" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">product</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>instance of <a href="Product.html">AboutYou::SDK::Model::Product</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-quantity" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">quantity</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>integer quantity</p>
        
        </div>
      </div>
      
      <div id="attribute-i-retail_price" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">retail_price</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer retail price</p>
        
        </div>
      </div>
      
      <div id="attribute-i-season_code" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">season_code</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>string <a href="Variant.html#attribute-i-season_code">#season_code</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-selected_image" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">selected_image</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>instance of <a href="Image.html">AboutYou::SDK::Model::Image</a></p>
        
        </div>
      </div>
      
      <div id="attribute-i-updated_date" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">updated_date</span><span
            class="attribute-access-type">[RW]</span>
        </div>

        <div class="method-description">
        
        <p>Integer update Date</p>
        
        </div>
      </div>
      
    </section>
    

    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Class Methods</h3>
       </header>

    
      <div id="method-c-create_from_json" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">create_from_json</span><span
            class="method-args">(json_object, factory, product)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for creating an instance of this class by a
json_object.</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; the json_object received from the api</p>
</li><li>
<p><code>factory</code> -&gt; instance of <a
href="../Factory/DefaultModelFactory.html">AboutYou::SDK::Factory::DefaultModelFactory</a></p>
</li><li>
<p><code>product</code> -&gt; <a href="Product.html">Product</a> of this
variant</p>
</li></ul>
</li><li>
<p><strong>Fails</strong> :</p>
<ul><li>
<p>if json_object has no id</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Instance of <a href="Variant.html">AboutYou::SDK::Model::Variant</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="create_from_json-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 68</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">create_from_json</span>(<span class="ruby-identifier">json_object</span>, <span class="ruby-identifier">factory</span>, <span class="ruby-identifier">product</span>)
  <span class="ruby-identifier">fail</span> <span class="ruby-string">'MalformedJsonException'</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'id'</span>]

  <span class="ruby-identifier">variant</span>                   = <span class="ruby-identifier">new</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">factory</span>           = <span class="ruby-identifier">factory</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">product</span>           = <span class="ruby-identifier">product</span>

  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">images</span>            = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">parse_images</span>(<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'images'</span>])
  <span class="ruby-comment"># free memory</span>
  <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'images'</span>]     = <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">id</span>                = <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'id'</span>]
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">about_number</span>      = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'about_number'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'about_number'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">ean</span>               = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'ean'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'ean'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">is_default</span>        = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'default'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">price</span>             = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'price'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'price'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">old_price</span>         = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'old_price'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'old_price'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">retail_price</span>      = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'retail_price'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'retail_price'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">additional_info</span>   = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'additional_info'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'additional_info'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">quantity</span>          = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'quantity'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'quantity'</span>] <span class="ruby-operator">:</span> <span class="ruby-value">0</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">first_active_date</span> = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'first_active_date'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'first_active_date'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">first_sale_date</span>   = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'first_sale_date'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'first_sale_date'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">created_date</span>      = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'created_date'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'created_date'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">updated_date</span>      = (<span class="ruby-identifier">json_object</span>[<span class="ruby-string">'updated_date'</span>]) <span class="ruby-operator">?</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'updated_date'</span>] <span class="ruby-operator">:</span> <span class="ruby-keyword">nil</span>

  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_ids</span>         = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">parse_facet_ids</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_groups</span>      = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">generate_facet_group_set</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">color</span>             = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group</span>(<span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Facet</span><span class="ruby-operator">::</span><span class="ruby-constant">FACET_COLOR</span>)
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">length</span>            = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group</span>(<span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Facet</span><span class="ruby-operator">::</span><span class="ruby-constant">FACET_LENGTH</span>)
  <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">season_code</span>       = <span class="ruby-identifier">variant</span>.<span class="ruby-identifier">facet_group</span>(<span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Facet</span><span class="ruby-operator">::</span><span class="ruby-constant">FACET_SEASON_CODE</span>)

  <span class="ruby-identifier">variant</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
       <header>
         <h3>Public Instance Methods</h3>
       </header>

    
      <div id="method-i-facet_group" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">facet_group</span><span
            class="method-args">(group_id)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method searches by a certain facet group id</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>group_id</code> -&gt; The group_id used for searching</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / instance of <a
href="FacetGroup.html">AboutYou::SDK::Model::FacetGroup</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="facet_group-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 212</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">facet_group</span>(<span class="ruby-identifier">group_id</span>)
  <span class="ruby-identifier">facet_groups</span>.<span class="ruby-identifier">group</span>(<span class="ruby-identifier">group_id</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-generate_facet_group_set" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">generate_facet_group_set</span><span
            class="method-args">(json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method generated a facet group set for a certain json_object</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; The json_object received from the api</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="generate_facet_group_set-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 198</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">generate_facet_group_set</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-identifier">ids</span> = <span class="ruby-identifier">parse_facet_ids</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">facet_groups</span> = <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">FacetGroupSet</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">ids</span>)
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-image" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">image</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for selected / default image</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / <a href="Image.html">AboutYou::SDK::Model::Image</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="image-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 162</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">image</span>
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">selected_image</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">selected_image</span>
  <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">images</span>[<span class="ruby-value">0</span>]
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">images</span>[<span class="ruby-value">0</span>]
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-image_by_hash" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">image_by_hash</span><span
            class="method-args">(hash)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method searches for an image by a certain hash</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>hash</code> -&gt; the hash used for searching</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / instance of <a href="Image.html">AboutYou::SDK::Model::Image</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="image_by_hash-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 129</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">image_by_hash</span>(<span class="ruby-identifier">hash</span>)
  <span class="ruby-identifier">images</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">image</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">image</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">image</span>.<span class="ruby-identifier">hash</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">hash</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_facet_ids" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_facet_ids</span><span
            class="method-args">(json_object)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method parses the facet ids of a certain json_object</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>json_object</code> -&gt; The json_object received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>{} / Hash containing pairs of group_id =&gt; attribute_ids</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_facet_ids-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 181</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_facet_ids</span>(<span class="ruby-identifier">json_object</span>)
  <span class="ruby-identifier">ids</span> = {}

  <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'attributes'</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">group</span>, <span class="ruby-identifier">attribute_ids</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">group_id</span> = <span class="ruby-identifier">group</span>[<span class="ruby-value">11</span><span class="ruby-operator">..</span><span class="ruby-identifier">group</span>.<span class="ruby-identifier">length</span>] <span class="ruby-comment"># rm prefix 'attributs_'</span>
    <span class="ruby-identifier">ids</span>[<span class="ruby-constant">Integer</span>(<span class="ruby-identifier">group_id</span>)] = <span class="ruby-identifier">attribute_ids</span>
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">json_object</span>[<span class="ruby-string">'attributes'</span>].<span class="ruby-identifier">empty?</span>

  <span class="ruby-identifier">ids</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-parse_images" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">parse_images</span><span
            class="method-args">(image_json)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for parsing images</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>image_json</code> -&gt; the image json_object received from the api</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li><dl class="rdoc-list label-list"><dt>
<dd>
<p>/ Array of instances of <a
href="Image.html">AboutYou::SDK::Model::Image</a></p>
</dd></dl>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="parse_images-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 111</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_images</span>(<span class="ruby-identifier">image_json</span>)
  <span class="ruby-identifier">image_array</span> = []
  <span class="ruby-identifier">image_json</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">image</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">image_array</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">factory</span>.<span class="ruby-identifier">create_image</span>(<span class="ruby-identifier">image</span>))
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">image_json</span>

  <span class="ruby-identifier">image_array</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-quantity_per_pack" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">quantity_per_pack</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the quantity per pack</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Integer quantity</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="quantity_per_pack-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 261</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">quantity_per_pack</span>
  <span class="ruby-identifier">facet_group</span> = <span class="ruby-identifier">facet_group</span>(
    <span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Facet</span><span class="ruby-operator">::</span><span class="ruby-constant">FACET_QUANTITY_PER_PACK</span>
  )
  <span class="ruby-keyword">return</span> <span class="ruby-value">1</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">facet_group</span>

  <span class="ruby-identifier">facets</span> = <span class="ruby-identifier">facet_group</span>.<span class="ruby-identifier">facets</span>
  <span class="ruby-keyword">return</span> <span class="ruby-value">1</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">facets</span>

  <span class="ruby-identifier">facets</span>[<span class="ruby-value">0</span>].<span class="ruby-identifier">value</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-select_image" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">select_image</span><span
            class="method-args">(hash = nil)</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>You can select an image with this method by a certain hash</p>
<ul><li>
<p><strong>Args</strong>    :</p>
<ul><li>
<p><code>hash</code> -&gt; the hash used for selecting [optional]</p>
</li></ul>
</li><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>Boolean determining whether the selection was successful or not</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="select_image-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 146</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">select_image</span>(<span class="ruby-identifier">hash</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">hash</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">selected_image</span> = <span class="ruby-identifier">image_by_hash</span>(<span class="ruby-identifier">hash</span>)
    <span class="ruby-keyword">true</span>
  <span class="ruby-keyword">else</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">selected_image</span> = <span class="ruby-keyword">nil</span>
    <span class="ruby-keyword">false</span>
  <span class="ruby-keyword">end</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-size" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">size</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>Getter for the size facet group</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>instance of <a href="FacetGroup.html">AboutYou::SDK::Model::FacetGroup</a></p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="size-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 222</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">size</span>
  <span class="ruby-comment"># @todo: Instance level caching</span>
  <span class="ruby-identifier">group_id</span> = <span class="ruby-identifier">size_group_id</span>
  <span class="ruby-identifier">facet_group</span>(<span class="ruby-identifier">group_id</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">group_id</span>.<span class="ruby-identifier">empty?</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
      <div id="method-i-size_group_id" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">size_group_id</span><span
            class="method-args">()</span>
          
          <span class="method-click-advice">click to toggle source</span>
          
        </div>
        

        <div class="method-description">
          
          <p>This method is used for getting the size group id</p>
<ul><li>
<p><strong>Returns</strong> :</p>
<ul><li>
<p>nil / group_id</p>
</li></ul>
</li></ul>
          
          

          
          <div class="method-source-code" id="size_group_id-source">
            <pre><span class="ruby-comment"># File lib/AboutYou/Model/variant.rb, line 234</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">size_group_id</span>
  <span class="ruby-identifier">keys</span> = {}
  <span class="ruby-identifier">groups</span> = <span class="ruby-identifier">facet_groups</span>.<span class="ruby-identifier">groups</span>
  <span class="ruby-identifier">size_run</span> = <span class="ruby-identifier">facet_group</span>(<span class="ruby-constant">AboutYou</span><span class="ruby-operator">::</span><span class="ruby-constant">SDK</span><span class="ruby-operator">::</span><span class="ruby-constant">Model</span><span class="ruby-operator">::</span><span class="ruby-constant">Facet</span><span class="ruby-operator">::</span><span class="ruby-constant">FACET_SIZE_RUN</span>)

  <span class="ruby-identifier">groups</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">group</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">keys</span>[<span class="ruby-identifier">group</span>.<span class="ruby-identifier">name</span>] = <span class="ruby-identifier">group</span>.<span class="ruby-identifier">group_id</span>
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">groups</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-constant">Array</span>)

  <span class="ruby-identifier">size_run</span>.<span class="ruby-identifier">facets</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">facet</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">group_name</span> = <span class="ruby-identifier">facet</span>.<span class="ruby-identifier">value</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">keys</span>[<span class="ruby-identifier">group_name</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-identifier">group_name</span>)
  <span class="ruby-keyword">end</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">size_run</span>.<span class="ruby-identifier">empty?</span>

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">keys</span>[<span class="ruby-string">'size'</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-string">'size'</span>)

  <span class="ruby-keyword">return</span> <span class="ruby-identifier">keys</span>[<span class="ruby-string">'size_run'</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">keys</span>.<span class="ruby-identifier">key?</span>(<span class="ruby-string">'size_run'</span>)

  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>
          
        </div>

        

        
      </div>

    
    </section>
  
  </section>
</main>


<footer id="validator-badges" role="contentinfo">
  <p><a href="http://validator.w3.org/check/referer">Validate</a>
  <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.2.
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
</footer>

